package com.xqyq.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.xqyq.dao.MatchDao;
import com.xqyq.dao.PrizeDao;
import com.xqyq.model.Match;
import com.xqyq.model.Prize;

@Service
public class PrizeService {
	
	@Autowired
	private PrizeDao prizeDao;
	@Autowired
	private MatchDao matchDao;
	
	public int addPrize(int match_id, String prize_name){
		Prize prize = new Prize();
		Match match = matchDao.getMatch(match_id);
		prize.setMatch(match);
		prize.setPrize_name(prize_name);
		return prizeDao.addPrize(prize);
	}
	
	@Transactional
	public void deletePrize(int prize_id){
		prizeDao.deletePrize(prize_id);
	}

}
